package com.suredy.app.porject.service;

import org.apache.commons.lang3.StringUtils;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Service;

import com.suredy.app.porject.model.BidResult;
import com.suredy.core.service.BaseSrvWithEntity;

@Service
public class BidResultSrv extends BaseSrvWithEntity<BidResult> {

	@Override
	public DetachedCriteria getDc(BidResult t) {
		DetachedCriteria dc = super.getDc(t);

		if (t == null)
			return dc;

		if (!StringUtils.isBlank(t.getId())) {
			dc.add(Restrictions.eq("id", t.getId()));
		}
		if (t.getStatus() != null) {
			dc.add(Restrictions.eq("status", t.getStatus()));
		}
		if (StringUtils.isBlank(t.getWinCompany())) {
			dc.add(Restrictions.like("winCompany", t.getWinCompany(), MatchMode.ANYWHERE));
		}

		return dc;
	}

}
